package cn.tedu.onlinestore.seller.controller;

import cn.tedu.onlinestore.base.response.JsonResult;
import cn.tedu.onlinestore.seller.pojo.dto.DianPuParam;
import cn.tedu.onlinestore.seller.pojo.vo.DianPuVO;
import cn.tedu.onlinestore.seller.service.SellerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/v1/seller/")
public class SellerController {
    @Autowired
    SellerService sellerService;
    @GetMapping("select/{username}")
    public JsonResult selectSellerById(@PathVariable String username){
        log.debug("sellerId:{}",username);
        DianPuVO dianPuVO = sellerService.selectSellerById(username);
        return JsonResult.ok(dianPuVO);
    }

    @GetMapping("getAllSeller")
    public JsonResult getAllSeller(Integer page,Integer size){
        log.debug("获取所有店铺");
        return JsonResult.ok(sellerService.getAllSeller(page,size));
    }

    @PostMapping("add")
    public JsonResult addDP(DianPuParam dianPuParam){
        log.debug("新增店铺：{}",dianPuParam);
        sellerService.addDP(dianPuParam);
        return JsonResult.ok();
    }

    @PostMapping("update")
    public JsonResult updateDP(DianPuParam dianPuParam){
        log.debug("修改店铺：{}",dianPuParam);
        sellerService.updateDP(dianPuParam);
        return JsonResult.ok();
    }
}
